package com.gewu.bookeeping.View.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.gewu.bookeeping.MyDb.bean.ALiBeanOut;
import com.gewu.bookeeping.MyDb.bean.WeChtBeanOut;
import com.gewu.bookeeping.OnClick.fourItemClieck;
import com.gewu.bookeeping.R;
import com.gewu.bookeeping.Utils.AppCot;

import java.util.ArrayList;
import java.util.List;

public class oneItem3Adapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private List<ALiBeanOut> AliLists;
    private List<WeChtBeanOut> WeCharts ;

    public void setAliLists(List<ALiBeanOut> aliLists) {
        AliLists = aliLists;
    }

    public void setWeCharts(List<WeChtBeanOut> weCharts) {
        WeCharts = weCharts;
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(parent.getContext()).inflate(R.layout.four_item2, parent, false);
        return new OneItems(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, final int position) {
        if (position<WeCharts.size()){
            ((OneItems)holder).textView.setText(WeCharts.get(position).getText());
        }else {
            ((OneItems)holder).textView.setText(AliLists.get(position-WeCharts.size()).getText());
        }

    }

    @Override
    public int getItemCount() {

        return (WeCharts.size()==0?0:WeCharts.size())+(AliLists.size()==0?0:AliLists.size());
    }

    /**
     * 地步item的管理
     */
    private class OneItems extends RecyclerView.ViewHolder {

        TextView textView;

        public OneItems(View inflate) {
            super(inflate);
            textView = inflate.findViewById(R.id.texts);
        }
    }
}
